package com.apes.hr.base.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 功能：人员教育背景
 * @author HuJianlin
 * @create 2018-04-25 15:11
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = EmployeeEducation.CONST_TABLE_NAME)
public class EmployeeEducation extends Model {
    public static final String CONST_TABLE_NAME = "hr_Employee_Education";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "人员教育背景")
    private long id; //编码

    @ManyToOne
    @JoinColumn(name = "employee_id", referencedColumnName="id")
    private Employee employee; //员工

    @ManyToOne
    @JoinColumn(name = "talent_pool_id", referencedColumnName="id")
    @Comment("人才储备")
    private TalentPool talentPool; //人才储备

    @Name
    @Column(name = "school_name", nullable = false, length = 200)
    private String schoolName; //学校名称

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "start_date")
    private Date startDate; //开始日期

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "end_date")
    private Date endDate; //结束日期

    @Name
    @Column(name = "specialty", length = 200)
    private String specialty;  //专业 nullable = false,

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "degree_id", referencedColumnName = "id")
    private Enumeration degree; //学历

    @Column(name = "has_diploma", nullable = false, columnDefinition = "number(1,0) default 1")
    private boolean hasDiploma = true; //有毕业证

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "educational_type_id", referencedColumnName = "id")
    private Enumeration educationalType; //学历类型

    @Name
    @Column(name = "education_certificate_no", length = 200)
    private String educationCertificateNo;  //大专及以上学历证书编号 nullable = false,

    @Name
    @Column(name = "degree_certificate_no", length = 200)
    private String degreeCertificateNo ;  //学位证书编号 nullable = false,

    @Name
    @Column(name = "sort_education")    //排序学列用的字段  博士  90>硕士   80>本科  70>大专  60  >电大  50>
    private String sortEducation ;          // 高中  40>高技  30>中专  20>中技  10>高中级以下  0   -1 无填写



}
